<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Circle</title>
</head>
<script type='text/javascript' src='<%=basePath%>dwr/engine.js'></script>  
<script type='text/javascript' src='<%=basePath%>dwr/util.js'></script> 
<script type='text/javascript' src='<%=basePath%>dwr/interface/MyDWR.js'></script>   
<script type='text/javascript'>
	window.onload = function() {
		
		
 		document.getElementById("button").onclick = function() {
 			
 			var a = document.getElementById("num1").value;
 			var b = document.getElementById("num2").value;
 			var c = document.getElementById("num3").value;
 			var d = document.getElementById("num4").value;
 			var e = document.getElementById("num5").value;
 			var f = document.getElementById("num6").value;
 			if(a==null||a==""||b==null||b=="") {
 				alert("a值b值不能为空");
 				return;
 			}
 			
 			var  list = {"num1":a,"num2":b,"num3":c,"num4":d,"num5":e,"num6":f};
 			//方法1：callback 利用回调函数获取java端的返回值
 	       /* 			
 	        MyDWR.add(a, b, {
				callback : function(str) {
					//alert(str);
					document.getElementById("num3").value = str;
					document.getElementById("showok").innerHTML = "计算成功"; 
				}
			});
 			 */
 			//方法2：出现超时处理时，对延迟进行处理
           			
            MyDWR.getList(JSON.stringify(list), {
 				  callback:function(str) { 
 					alert(str);
 					document.getElementById("showok").innerHTML = "成功"; 
 				  },
 				  timeout:200,
 				  errorHandler:function(message) { alert("出错原因: " + message); }
 				});
 		

  
		}
		
		
		
	};
</script>  
<body>
<table>
<tr>
<td>
<input type="text" value="1" id="num1" name="num1" />
</td>
<td>
→
</td>
<td>
<input type="text" value="2" id="num2" name="num2" />
</td>
<td>
→
</td>
<td>
<input type="text" value="3" id="num3" name="num3" />
</td>
</tr>

<tr>
<td>
<input type="text" value="6" id="num6" name="num6" />
</td>
<td>
←
</td>
<td>
<input type="text" value="5" id="num5" name="num5" />
</td>
<td>
←
</td>
<td>
<input type="text" value="4" id="num4" name="num4" />
</td>
</tr>
</table>
<input type="button" value="点击一下" id="button" name="button" />
<div id="showok">
</div>
</body>
</html>